#!/usr/bin/perl
### 
### Perl method of Ryan Woodsmall's Wine installer, with some extra
### packages that the MacPort's team uses.
### 
### Things to do:
###	Allow for multiple locations in case a server goes down.
###	Check to see how many threads to use.
###	Run on multiple versions of OS/X right now it's only for Lion.
### 	Dynamically set the number of "make" threads to run.
###	Add jbigkit to the install since it's a funky install.

### v.25 - Initial Version 
### v.30 - Added the SHA1 checking
### v.35 - Changed it from using GLOBAL "CFLAG" etc settings 
###      - to LOCAL settings for each package.  Takes up more 
###      - space this way, but allows for greater flexibility.
### v.36 - Fixed a couple of issues with the option parser.
### v.37 - Changed most of the prerequisites sites to this 
###      - project's svn.

### Though I try to keep everything contained and error free as much as
### possible the use of this script is "use at your own risk". 

${OPTION} = shift;

###
### Global Variables...
###
### Setting the Wine Version here.
${WINEVER}="wine-1.4-rc3";

### Setting the base directory (The directory this script is launched from.)
${BASEDIR}=`/bin/pwd`; chomp ${BASEDIR};
${TMPDIR}="${BASEDIR}/tmp";

### Check how many cores this machine has
my ${CORECOUNT} = `sysctl -n machdep.cpu.core_count`;
chomp ${CORECOUNT};
### Incrementing it 1 to just keep everything busy.
${CORECOUNT}++;

### Setting the build directory (The directory where the binaries will end up.)
${BUILDDIR}="${BASEDIR}/${WINEVER}";

### Setting the PATH so that something will compile right.
${CURRENTPATH} = $ENV{PATH};
$ENV{PATH} = "${BUILDDIR}/bin:${CURRENTPATH}";

### Setting the verbosity level
$VERBOSE = 0;

###
### This is where the "fun" begins
###
${OS_VERSION} = `uname -r`;

SWITCH: foreach(${OS_VERSION}) {
	/^11./i && do {
		print "\nOS/X 10.7 (Lion) Detected.\n";
		###
		### Which X11?
		###
		${X11DIR}="/usr/X11";
		${ERROROUT} = system ( "launchctl list | grep -i startx | grep -i xquartz >/dev/null 2>&1" );
		if ( ${ERROROUT} == 0 ) {
			print "+ XQuartz found.\n";
			if ( -e "/opt/X11" ) {
				print "+ Using XQuartz in /opt/X11.\n";
				${X11DIR}="/opt/X11";
			} else {
				print "- XQuartz launchd found, but no /opt/X11.  Check your installation if\n";
				print "- you want to use XQuartz.  Defaulting to the system X11.\n";
			}
		} else {
			print "+ Using the system X11.\n";
		}
		last SWITCH;
	};
	/^10./i && do {
		die "- This OS Version is not supported yet.\n";
		last SWITCH;
	};
	/^9./i && do {
		die "- This OS Version is not supported yet.\n";
		last SWITCH;
	};
	die "- This OS Version is not supported yet.\n";
}
###
### Compiler Global Variables. (Need to change, for flexibility.)
### I'll probably move this to each application for ease of future changes.
###
### ${G_CPUFLAGS}="-mmmx -msse -msse2 -msse3 -mfpmath=sse";
###### ${G_CPUFLAGS}="-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
### ${G_LDFLAGS}="-L/usr/lib -L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU";
### ${G_CPPFLAGS}="-I/usr/include -I${BUILDDIR}/include -I${X11DIR}/include";
### ${G_CFLAGS}="-L/usr/lib -L${BUILDDIR}/lib ${G_CPUFLAGS}";
### ${G_CXXFLAGS}="${G_CFLAGS}";

###
### Create the output directory if it doesn't exist.
###
print "Base directory: ${BASEDIR}\n";

${MAKEME} = "${BASEDIR}/output";
if ( -e "${MAKEME}" ) {
	print "Output directory ${MAKEME} already exists, not creating.\n";
} else {
	print "Creating output directory ${MAKEME}.\n";
	system ( "/bin/mkdir ${MAKEME}" );
}

if ( -e "${TMPDIR}" ) {
	print "Temporary directory ${TMPDIR} already exists, not creating.\n";
} else {
	print "Creating temporary directory ${TMPDIR}.\n";
	system ( "/bin/mkdir ${TMPDIR}" );
}

SWITCH: foreach(${OPTION}) {
	/--verbose$/i && do {
		$VERBOSE = 1;
		last SWITCH;
	};
	/--update$/i && do {
		delete_check_point ("wine");
		last SWITCH;
	};
	/--cleangcc$/i && do {
		print "Removing gcc and associated packages.\n";
		system ( "rm -rf \"${BASEDIR}/build/gcc-4.6.1\"");
		system ( "rm -rf \"${BASEDIR}/build/mpfr-2.4.2\"");
		system ( "rm -rf \"${BASEDIR}/build/mpc-0.8.1\"");
		system ( "rm -rf \"${BASEDIR}/build/gmp-4.3.2\"");
		print "Done.\n";
		last SWITCH;
	};
	/--clean$/i && do {
		print "Cleaning...\n\n";
		print "Removing ${BUILDDIR}\n";
		system ( "rm -rf \"${BUILDDIR}\"");
		print "Removing ${BASEDIR}/build\n";
		system ( "rm -rf \"${BASEDIR}/build\"");
		print "Removing ${BASEDIR}/output\n";
		system ( "rm -rf \"${BASEDIR}/output\"");
		print "Removing ${BASEDIR}/tmp\n";
		system ( "rm -rf \"${BASEDIR}/tmp\"");
		die "\nCleaned.\n";
		last SWITCH;
	};
	/--help$/i && do {
		print "\n";
		print "Options for this scripts are:\n";
		print "  --cleangcc - Removes the gcc in the build directory, for some reason I've yet\n";
		print "               to debug that sometimes gcc doesn't build the first time through\n";
		print "               this script.  So you this option if you get that.\n";
		print "  --clean    - Removes the build, output, tmp and the ${BUILDDIR} directories.\n";
		print "               Use this if you're wanting a clean build.\n";
		print "  --help     - This text.\n";
		print "  --update   - Just rebuilds wine.  **Note** - Make sure you \n";
		print "               change the \${WINEVER}=\"\" setting in the script to match\n";
		print "               your old build directory else it's not going to work correctly.\n";
		print "               i.e. change to \${WINEVER}=\"wine-1.3.31\"\n";
		print "  --verbose  - Builds with more output, useful in debugging.\n";
		print "\n";
		print "This script does not accept multiple option at this point in time.\n";
		die "\n";
		last SWITCH;
	};
}


###
### My Functions below here
###

### This function creates a "check point" (if wanted) incase
### something happens that causes the script to be interrupted.
sub create_check_point {
        my ${CHKPOINTNAME} = $_[0]; ### This will usually be something like
                                    ### a hostname or someother unique parameter.

        my ${CMD} = "touch ${TMPDIR}/${CHKPOINTNAME}";
        ${RC} = system ( "${CMD}" );
        if ( ${RC} > 0 ) {
                die "Unable to : ${CMD}\n";
        }
        return 0;
}

### This function checks for a "check point" (if wanted)
sub check_check_point {
        my ${CHKPOINTNAME} = $_[0]; ### This will usually be something like
                                  ### a hostname or someother unique parameter.
        my ${RETURN} = 1; ### We'll assume failure unless otherwise found.

        my ${CHKPNT} = "${TMPDIR}/${CHKPOINTNAME}";
        if ( -e "${CHKPNT}" ) {
                ${RETURN} = 0;
        }
        return ${RETURN};
}

### This function deletes a "check point" (if wanted)
sub delete_check_point {
        my ${CHKPOINTNAME} = $_[0]; ### This will usually be something like
                                  ### a hostname or someother unique parameter.
        my ${CMD} = "rm ${TMPDIR}/${CHKPOINTNAME}";
        ${RC} = system ( "${CMD}" );
        if ( ${RC} > 0 ) {
                die "Unable to : ${CMD}\n";
        }
        return 0;
}

###
### Makes an attempt to download the passed file.
###
sub get_source {
	### We'll assume that this function returns ok unless otherwise found.
	my ${RETURN} = 0;
	###
	### Create the source directory if it doesn't exist.
	###
	if ( -e "${BASEDIR}/source" ) {
	} else {
		system ( "/bin/mkdir ${BASEDIR}/source" );
	}
	
	### Program we're going to use to get files is set in the "FILEGETTER" variable.
	###
	my ${FILEGETTER} = "/usr/bin/curl -kL $_[0]/$_[1] -o $_[2] > /dev/null 2>&1";

	if ( -e $_[2] ) {
		print "\nFile \"$_[1]\" already exists, not downloading.\n";
	} else {
		print "\nDownloading \"$_[1]\".\n";
		my ${ERROROUT} = system ( "${FILEGETTER}" );
		if ( -e $_[2] ) {
			print "+ $_[0]/$_[1] downloaded.\n";
		} else {
			die "Failed to get file: $_[0];$_[1]\n";
			${RETURN} = 1;
		}
	}

	return ${RETURN}
}

###
### Makes an attempt to extract the passed file.
###
sub extract_source {
	### We'll assume that this function returns ok unless otherwise found.
	${RETURN} = 0;
	###
	### Create the build directory if it doesn't exist.
	###
	if ( -e "${BASEDIR}/build" ) {
	} else {
		system ( "/bin/mkdir ${BASEDIR}/build" );
	}

	SWITCH: foreach($_[0]) {
		m/tar.gz/i && do {
			${EXTRACTME} = "cd $_[1] ; /usr/bin/gzcat $_[0] | /usr/bin/tar xvf - > /dev/null 2>&1";
			last SWITCH;
		};
		m/tar.bz2/i && do {
			${EXTRACTME} = "cd $_[1] ; /usr/bin/bzcat $_[0] | /usr/bin/tar xvf - > /dev/null 2>&1";
			last SWITCH;
		};
		m/.tgz/i && do {
			${EXTRACTME} = "cd $_[1] ; /usr/bin/tar zxvf $_[0] > /dev/null 2>&1";
			last SWITCH;
		};
		m/.zip/i && do {
			${EXTRACTME} = "cd $_[1] ; /usr/bin/unzip $_[0] > /dev/null 2>&1";
			last SWITCH;
		};
		die "- Unknown file extention.\n";
	}
	
	if ( -e $_[0] ) {
		print "+ extracting $_[0].\n";
		my ${ERROROUT} = system ( "${EXTRACTME}" );
		print "+ $_[0] extracted.\n";
	} else {
		print "The file $_[0] was not found!\n";
		${RETURN} = 1;
	}
}

###
### Makes an attempt to configure the passed source.
###
sub configure_source {
	### $_[0] = Build directory
	### $_[1] = Environment Variables
	### $_[2] = Configure Variables
	### $_[3] = Special Configure command
	
	### We'll assume that this function returns ok unless otherwise found.
	${RETURN} = 0;
	### Assuming that the configure script is called "configure" unless something was passed
	if ( $_[3] ne "" ) {
		${CONFIGURE} = "$_[3]";
	} else {
		${CONFIGURE} = "./configure";
	}

	my ${CONFIGUREME} = "cd ${BASEDIR}/build/$_[0] ; $_[1] ${CONFIGURE} $_[2] > ${BASEDIR}/output/$_[0].configure 2>&1";
	
	if ( -e "${BASEDIR}/build/$_[0]" ) {
		if ( ${VERBOSE} == 1 ) {
			print "R: ${CONFIGUREME}\n";
		}
		print "+ configuring $_[0].\n";
		my ${ERROROUT} = system ( "${CONFIGUREME}" );
		if ( ${ERROROUT} != 0 ) {
			die "- Unable to configure $_[0]\n";
		} else {
			print "+ $_[0] configured.\n";
		}
	} else {
		print "- Directory $_[0] not found!\n";
		${RETURN} = 1;
	}

	return ${RETURN};
}

###
### Makes an attempt to build the passed source.
###
sub build_source {
	### $_[0] = Build directory
	### $_[1] = Make options
	### $_[2] = Different logfile
	### Assumes the make command is "make";
	${MAKE} = "make";
	if ( $_[2] eq "" ) {
		${MAKEME} = "cd ${BASEDIR}/build/$_[0] ; ${MAKE} $_[1] > ${BASEDIR}/output/$_[0].make 2>&1";
	} else {
		${MAKEME} = "cd ${BASEDIR}/build/$_[0] ; ${MAKE} $_[1] > ${BASEDIR}/output/$_[2].make 2>&1";
	}
	
	if ( -e "${BASEDIR}/build/$_[0]" ) {
		if ( ${VERBOSE} == 1 ) {
			print "R: ${MAKEME}\n";
		}
		print "+ building $_[0].\n";
		my ${ERROROUT} = system ( "${MAKEME}" );

		if ( ${ERROROUT} != 0 ) {
			die "- Unable to build $_[0]\n";
		} else {
			print "+ $_[0] built.\n";
		}

	} else {
		die "- Cannot locate: $_[0]\n";
	}
}

###
### Makes an attempt to install the built source.
###
sub install_source {
	### $_[0] = Build directory
	### $_[1] = Alternate Output
	### Assumes the make command is "make";
	${MAKE} = "make install";
	if ( $_[1] eq "" ) {
		${MAKEME} = "cd ${BASEDIR}/build/$_[0] ; ${MAKE} > ${BASEDIR}/output/$_[0].install 2>&1";
	} else {
		${MAKEME} = "cd ${BASEDIR}/build/$_[0] ; ${MAKE} > ${BASEDIR}/output/$_[1].install 2>&1";
	}
	
	if ( -e "${BASEDIR}/build/$_[0]" ) {
		if ( ${VERBOSE} == 1 ) {
			print "R: ${MAKEME}\n";
		}
		print "+ installing $_[0].\n";
		my ${ERROROUT} = system ( "${MAKEME}" );

		if ( ${ERROROUT} != 0 ) {
			die "- Unable to install $_[0]\n";
		} else {
			print "+ $_[0] installed.\n";
		}

	} else {
		die "- Cannot locate: $_[0]\n";
	}
}

###
### Checks the SHA1 digests
###
sub check_sha {
	my ${FILE} = $_[0];
	my ${EXPECTED} = $_[1];
	my ${RETURN} = 1;  ### Assume failure.
	
	print "Checking ${FILE}.\n";
	my ${SSLCMD} = "/usr/bin/openssl dgst -sha1 < ${FILE} |";
	my ${RESULT} = "";
	
	open (CMD, ${SSLCMD}) or die "Cannot run: ${SSLCMD} \n"; 
	while (<CMD>) {
		${RESULT} = $_;	
		chomp ${RESULT};
	}
	close (CMD);

	if ( "${RESULT}x" eq "${EXPECTED}x" ) {
		print "+ ${FILE} passed.\n";
		${RETURN} = 0;
	} else { 
		system ( "rm ${FILE}" );
		print "- ${FILE} doesn't match the expect SHA1 string!\n";
		print "- Removing ${FILE}, please restart this script\n";
		die ("- and it should re-try the download of this file.\n");
	}
	return ${RETURN};
}

### 
### After this point is when we start to really do "stuff".
###

###
### pkg-config
###

sub install_pkg_config {
	${CHKPNT} = check_check_point ("pkg-config");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "pkg-config-0.25.tar.gz";
		${SOURCEDIR}    = "pkg-config-0.25";
		${SOURCEHASH}   = "fd71a70b023b9087c8a7bb76a0dc135a61059652";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
	
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		#check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
	
		create_check_point ("pkg-config");
	}
}
	
	###
	### libiconv
	###
	
sub install_libiconv {
	${CHKPNT} = check_check_point ("libiconv");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "libiconv-1.14.tar.gz";
		${SOURCEDIR}    = "libiconv-1.14";
		${SOURCEHASH}   = "be7d67e50d72ff067b2c0291311bc283add36965";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-static";
		${AFTER_CONFIGURE} .= " --docdir=${BUILDDIR}/share/doc/libiconv";
		${AFTER_CONFIGURE} .= " --without-libiconv-prefix";
		${AFTER_CONFIGURE} .= " --without-linintl-prefix"; 
		${AFTER_CONFIGURE} .= " --disable-nls";
		${AFTER_CONFIGURE} .= " --enable-extra-encodings";
	
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("libiconv");
	}
}
	
	###
	### gettext
	###
	
sub install_gettext {
	${CHKPNT} = check_check_point ("gettext");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "gettext-0.18.1.1.tar.gz";
		${SOURCEDIR}    = "gettext-0.18.1.1";
		${SOURCEHASH}   = "5009deb02f67fc3c59c8ce6b82408d1d35d4e38f";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS} -no-cpp-precomp\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
		${AFTER_CONFIGURE} .= " --disable-csharp";
		${AFTER_CONFIGURE} .= " --disable-native-java";
		${AFTER_CONFIGURE} .= " --without-emacs";
		${AFTER_CONFIGURE} .= " --with-included-gettext";
		${AFTER_CONFIGURE} .= " --with-included-glib";
		${AFTER_CONFIGURE} .= " --with-included-libcroco";
		${AFTER_CONFIGURE} .= " --with-included-libxml";
	
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		### Still have to make the hack to the source.
		print "Making the hack to the gettext source to compile on Lion.\n";
		`perl -pi -e 's/^# define __stpncpy stpncpy//' ${BASEDIR}/build/gettext-0.18.1.1/gettext-tools/gnulib-lib/stpncpy.c`;
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("gettext");
	}
}
	
	###
	### jpeg
	###
	
sub install_jpeg {
	${CHKPNT} = check_check_point ("jpeg");
	if ( ${CHKPNT} == 1 ) {
	
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "jpegsrc.v8c.tar.gz";
		${SOURCEDIR}    = "jpeg-8c";
		${SOURCEHASH}   = "f0a3b88ac4db19667798bee971537eeed552bce9";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
		
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("jpeg");
	}
}
	
	###
	### jbigkit
	###
	
	#${CHKPNT} = check_check_point ("jbigkit");
	#if ( ${CHKPNT} == 1 ) {
	#
	#	${SOURCESERVER} = "http://www.cl.cam.ac.uk/~mgk25/download";
	#	${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
	#	${SOURCECODE}   = "jbigkit-2.0.tar.gz";
	#	${SOURCEDIR}    = "jbigkit";
	#	${SOURCEHASH}   = "cfb7d3121f02a74bfb229217858a0d149b6589ef";
	#
	#	${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
	#	${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
	#	${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
	#	${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
	#	${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
	#	
	#	get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
	#	check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
	#	extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
	#	configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
	#	build_source ("${SOURCEDIR}", "-j 5");
	#	install_source ("${SOURCEDIR}");
	#	create_check_point ("jbigkit");
	#}
	
	###
	### tiff
	###
	
sub install_tiff {
	${CHKPNT} = check_check_point ("tiff");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "tiff-3.9.5.tar.gz";
		${SOURCEDIR}    = "tiff-3.9.5";
		${SOURCEHASH}   = "f40aab20fb2f609b5cbc1171c40b66a1445e3773";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
		${AFTER_CONFIGURE} .= " --with-jpeg-include-dir=${BUILDDIR}/include";
		${AFTER_CONFIGURE} .= " --with-jpeg-lib-dir=${BUILDDIR}/lib";
		
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("tiff");
	}
}
	
	###
	### libpng
	###
	
sub install_libpng {
	${CHKPNT} = check_check_point ("libpng");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "libpng-1.2.44.tar.gz";
		${SOURCEDIR}    = "libpng-1.2.44";
		${SOURCEHASH}   = "776bb8e42d86bd71ae58e0d96f85472c1d63beeb";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
		
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("libpng");
	}
}
	
	###
	### glib
	###
	
sub install_glib {
	${CHKPNT} = check_check_point ("glib");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "glib-2.28.8.tar.bz2";
		${SOURCEDIR}    = "glib-2.28.8";
		${SOURCEHASH}   = "20cd63705a8805260da0320c65b979233f2e3c18";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS} -bind_at_load\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS} -fstrict-aliasing\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
		
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("glib");
	}
}
	
	###
	### libxml2
	###
	
sub install_libxml2 {
	${CHKPNT} = check_check_point ("libxml2");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "libxml2-2.7.8.tar.gz";
		${SOURCEDIR}    = "libxml2-2.7.8";
		${SOURCEHASH}   = "859dd535edbb851cc15b64740ee06551a7a17d40";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS} -m32\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
		${AFTER_CONFIGURE} .= " --enable-static";
		${AFTER_CONFIGURE} .= " --without-python";
		
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("libxml2");
	}
}
	
	###
	### libxslt
	###
	
sub install_libxslt {
	${CHKPNT} = check_check_point ("libxslt");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "libxslt-1.1.26.tar.gz";
		${SOURCEDIR}    = "libxslt-1.1.26";
		${SOURCEHASH}   = "69f74df8228b504a87e2b257c2d5238281c65154";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS} -m32\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-static";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
		${AFTER_CONFIGURE} .= " --with-libxml-prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --without-python";
		${AFTER_CONFIGURE} .= " --without-crypto";
		
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("libxslt");
	}
}
	
	###
	### mpg123
	###
	
sub install_mpg123 {
	${CHKPNT} = check_check_point ("mpg123");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "mpg123-1.13.2.tar.bz2";
		${SOURCEDIR}    = "mpg123-1.13.2";
		${SOURCEHASH}   = "31a9c27f5fa80f930dbe598846c847f9b35d9dc3";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "CC=\"gcc -read_only_relocs suppress\"";
		${BEFORE_CONFIGURE} .= " LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --with-cpu=x86";
		
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		create_check_point ("mpg123");
	}
}
		
	###
	### gsm
	###
	
sub install_gsm {
	${CHKPNT} = check_check_point ("gsm");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "gsm-1.0.13.tar.gz";
		${SOURCEDIR}    = "gsm-1.0-pl13";
		${SOURCEHASH}   = "668b0a180039a50d379b3d5a22e78da4b1d90afc";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
		
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		### There's no "configure" script for this software, gotta hack it together.
		### configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
	
		`sed -i .bak 's!^INSTALL_ROOT	=!INSTALL_ROOT	=${BUILDDIR}!' ${BASEDIR}/source/${SOURCEDIR}/Makefile`;
		build_source ("${SOURCEDIR}", "-j 5");
		`cp ${BASEDIR}/build/${SOURCEDIR}/lib/* ${BUILDDIR}/lib/.`;
		`cp ${BASEDIR}/build/${SOURCEDIR}/inc/gsm.h ${BUILDDIR}/include/.`;
		`cp ${BASEDIR}/build/${SOURCEDIR}/bin/* ${BUILDDIR}/bin/.`;
		create_check_point ("gsm");
	}
}
	
	###
	### freetype
	###
	
sub install_freetype {
	${CHKPNT} = check_check_point ("freetype");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "freetype-2.4.6.tar.bz2";
		${SOURCEDIR}    = "freetype-2.4.6";
		${SOURCEHASH}   = "9d874398118c805478e81d80449dc4aa5a40b6f2";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
		
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("freetype");
	}
}
	
	###
	### fontconfig
	###
	
sub install_fontconfig {
	${CHKPNT} = check_check_point ("fontconfig");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "fontconfig-2.8.0.tar.gz";
		${SOURCEDIR}    = "fontconfig-2.8.0";
		${SOURCEHASH}   = "570fb55eb14f2c92a7b470b941e9d35dbfafa716";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
		${AFTER_CONFIGURE} .= " --with-add-fonts=/usr/X11R6/lib/X11/fonts";
		${AFTER_CONFIGURE} .= " --with-add-fonts=/Library/Fonts";
		${AFTER_CONFIGURE} .= " --with-add-fonts=/Network/Library/Fonts";
		${AFTER_CONFIGURE} .= " --with-add-fonts=${BUILDDIR}/share/fonts";
		
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("fontconfig");
	}
}
	
	###
	### lcms
	###
	
sub install_lcms {
	${CHKPNT} = check_check_point ("lcms");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "lcms-1.19.tar.gz";
		${SOURCEDIR}    = "lcms-1.19";
		${SOURCEHASH}   = "d5b075ccffc0068015f74f78e4bc39138bcfe2d4";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
		
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("lcms");
	}
}
		
	###
	### lzo2
	###
	
sub install_lzo2 {
	${CHKPNT} = check_check_point ("lzo2");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "lzo-2.05.tar.gz";
		${SOURCEDIR}    = "lzo-2.05";
		${SOURCEHASH}   = "2307bcd0d13f1d53b623a54094c33b703544111c";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
		${AFTER_CONFIGURE} .= " --enable-shared";
		${AFTER_CONFIGURE} .= " --enable-static";
		${AFTER_CONFIGURE} .= " --disable-asm";
		
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("lzo2");
	}
}
	
	###
	### libgpgerror
	###
	
sub install_libgpgerror {
	${CHKPNT} = check_check_point ("libgpgerror");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "libgpg-error-1.10.tar.bz2";
		${SOURCEDIR}    = "libgpg-error-1.10";
		${SOURCEHASH}   = "95b324359627fbcb762487ab6091afbe59823b29";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
		
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("libgpgerror");
	}
}
		
	###
	### libgcrypt
	###
	
sub install_libgcrypt {
	${CHKPNT} = check_check_point ("libgcrypt");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "libgcrypt-1.5.0.tar.bz2";
		${SOURCEDIR}    = "libgcrypt-1.5.0";
		${SOURCEHASH}   = "3e776d44375dc1a710560b98ae8437d5da6e32cf";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
		${AFTER_CONFIGURE} .= " --disable-asm";
		${AFTER_CONFIGURE} .= " --with-gpg-error-prefix=${BUILDDIR}";
		
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("libgcrypt");
	}
}
		
	###
	### gnutils
	###
	
sub install_gnutils {
	${CHKPNT} = check_check_point ("gnutils");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "gnutls-2.8.6.tar.bz2";
		#${SOURCECODE}   = "gnutls-3.0.5.tar.xz";
		${SOURCEDIR}    = "gnutls-2.8.6";
		#${SOURCEDIR}    = "gnutls-3.0.5";
		${SOURCEHASH}   = "bff911d4fd7389aa6698a644b3748eb2d23715bc";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS} -m32\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
		${AFTER_CONFIGURE} .= " --with-lzo";
		${AFTER_CONFIGURE} .= " --disable-guile";
		
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		#check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("gnutils");
	}
}
		
	###
	### unixodbc
	###
	
sub install_unixodbc {
	${CHKPNT} = check_check_point ("unixodbc");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "unixODBC-2.3.0.tar.gz";
		${SOURCEDIR}    = "unixODBC-2.3.0";
		${SOURCEHASH}   = "b2839b5210906e3ee286a4b621f177db9c7be7a8";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
	
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("unixodbc");
	}
}
	
	###
	### libexif
	###

sub install_libexif {	
	${CHKPNT} = check_check_point ("libexif");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "libexif-0.6.20.tar.bz2";
		${SOURCEDIR}    = "libexif-0.6.20";
		${SOURCEHASH}   = "d7cce9098169269695852db20d24350c2d3c10fe";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
	
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("libexif");
	}
}
	
	###
	### libusb
	###
	
sub install_libusb {
	${CHKPNT} = check_check_point ("libusb");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "libusb-1.0.8.tar.bz2";
		${SOURCEDIR}    = "libusb-1.0.8";
		${SOURCEHASH}   = "5484397860f709c9b51611d224819f8ed5994063";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${BEFORE_CONFIGURE} .= " LIBUSB_LIBS=\"${BUILDDIR}\lib\"";
		${BEFORE_CONFIGURE} .= " LIBUSB_CFLAGS=\"${BUILDDIR}\include\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
	
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("libusb");
	}
}
	
	###
	### libusbcompat
	###
	
sub install_libusbcompat {
	${CHKPNT} = check_check_point ("libusbcompat");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "libusb-compat-0.1.3.tar.bz2";
		${SOURCEDIR}    = "libusb-compat-0.1.3";
		${SOURCEHASH}   = "d5710d5bc4b67c5344e779475b76168c7ccc5e69";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
	
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("libusbcompat");
	}
}
		
	###
	### gd
	###
	
sub install_gd {
	${CHKPNT} = check_check_point ("gd");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "gd-2.0.36RC1.tar.bz2";
		${SOURCEDIR}    = "gd-2.0.36RC1";
		${SOURCEHASH}   = "415300e288348ed0d806fa2f3b7815604d8b5eec";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
	
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("gd");
	}
}
	
	###
	### libgphoto2
	###
	
sub install_libgphoto2 {
	${CHKPNT} = check_check_point ("libgphoto2");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "libgphoto2-2.4.10.1.tar.bz2";
		${SOURCEDIR}    = "libgphoto2-2.4.10.1";
		${SOURCEHASH}   = "2806b147d3cf2c3cfdcb5cb8db8b82c1180d5f36";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
		${PKG_CONFIG} = "${BUILDDIR}/lib/pkgconfig:/usr/lib/pkgconfig:${X11DIR}/lib/pkgconfig";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${BEFORE_CONFIGURE} .= " PKG_CONFIG_PATH=\"${PKG_CONFIG}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
		${AFTER_CONFIGURE} .= " --with-libexif=auto";
		${AFTER_CONFIGURE} .= " --with-libusb=no";
	
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("libgphoto2");
	}
}
	
	###
	### jasper
	###
	
sub install_jasper {
	${CHKPNT} = check_check_point ("jasper");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "jasper-1.900.1.zip";
		${SOURCEDIR}    = "jasper-1.900.1";
		${SOURCEHASH}   = "9c5735f773922e580bf98c7c7dfda9bbed4c5191";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
	
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("jasper");
	}
}
	
	###
	### libicns
	###
	
sub install_libicns {
	${CHKPNT} = check_check_point ("libicns");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "libicns-0.7.1.tar.gz";
		${SOURCEDIR}    = "libicns-0.7.1";
		${SOURCEHASH}   = "e12a6ca21988929d56320ac1b96a1a059af0fd43";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
	
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("libicns");
	}
}
	
	###
	### sdl
	###
	
sub install_sdl {
	${CHKPNT} = check_check_point ("sdl");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "SDL-1.2.14.tar.gz";
		${SOURCEDIR}    = "SDL-1.2.14";
		${SOURCEHASH}   = "7f3ebdd463f2a5c5576c31446fc7ac90c653b3d1";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE}  = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
	
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("sdl");
	}
}
	
	###
	### sdlnet
	###
	
sub install_sdlnet {
	${CHKPNT} = check_check_point ("sdlnet");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "SDL_net-1.2.7.tar.gz";
		${SOURCEDIR}    = "SDL_net-1.2.7";
		${SOURCEHASH}   = "b46c7e3221621cc34fec1238f1b5f0ce8972274d";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
	
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("sdlnet");
	}
}
	
	###
	### sdlsound
	###
	
sub install_sdlsound {
	${CHKPNT} = check_check_point ("sdlsound");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "SDL_sound-1.0.3.tar.gz";
		${SOURCEDIR}    = "SDL_sound-1.0.3";
		${SOURCEHASH}   = "1984bc20b2c756dc71107a5a0a8cebfe07e58cb1";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
	
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("sdlsound");
	}
}
	
	###
	### dosbox
	###
	
sub install_dosbox {
	${CHKPNT} = check_check_point ("dosbox");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "dosbox-0.74.tar.gz";
		${SOURCEDIR}    = "dosbox-0.74";
		${SOURCEHASH}   = "2d99f0013350efb29b769ff19ddc8e4d86f4e77e";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
	
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("dosbox");
	}
}
	
	###
	### orc
	###
	
sub install_orc { 
	${CHKPNT} = check_check_point ("orc");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "orc-0.4.11.tar.gz";
		${SOURCEDIR}    = "orc-0.4.11";
		${SOURCEHASH}   = "e99f684fc551c2bb3a5cdefe6fa5165174508a5f";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
	
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("orc");
	}
}
	
	###
	### libogg
	###
	
sub install_libogg { 
	${CHKPNT} = check_check_point ("libogg");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "libogg-1.2.2.tar.gz";
		${SOURCEDIR}    = "libogg-1.2.2";
		${SOURCEHASH}   = "deeb1959f84de9277e74bca17ec66fa20ced9f08";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
	
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("libogg");
	}
}
	
	###
	### libvorbis
	###
	
sub install_libvorbis {
	${CHKPNT} = check_check_point ("libvorbis");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "libvorbis-1.3.2.tar.bz2";
		${SOURCEDIR}    = "libvorbis-1.3.2";
		${SOURCEHASH}   = "4c44da8215d1fc56676fccc1af8dd6b422d9e676";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
	
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("libvorbis");
	}
}
	
	###
	### libtheora
	###
	
sub install_libtheora {
	${CHKPNT} = check_check_point ("libtheora");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "libtheora-1.1.1.tar.bz2";
		${SOURCEDIR}    = "libtheora-1.1.1";
		${SOURCEHASH}   = "8dcaa8e61cd86eb1244467c0b64b9ddac04ae262";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
	
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("libtheora");
	}
}
	
	###
	### gstreamer
	###
	
sub install_gstreamer {
	${CHKPNT} = check_check_point ("gstreamer");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "gstreamer-0.10.35.tar.bz2";
		${SOURCEDIR}    = "gstreamer-0.10.35";
		${SOURCEHASH}   = "ad03b8aca7b2415929b6ecc4c140b178acef39de";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
	
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("gstreamer");
	}
}
	
	###
	### gstpluginsbase
	###
	
sub install_gstpluginsbase {
	${CHKPNT} = check_check_point ("gstpluginsbase");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "gst-plugins-base-0.10.32.tar.bz2";
		${SOURCEDIR}    = "gst-plugins-base-0.10.32";
		${SOURCEHASH}   = "c1c149272b7ab6cbe5f648532f74525c6541eea5";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
	
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("gstpluginsbase");
	}
}
	
	###
	### cabextract
	###
	
sub install_cabextract { 
	${CHKPNT} = check_check_point ("cabextract");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "cabextract-1.3.tar.gz";
		${SOURCEDIR}    = "cabextract-1.3";
		${SOURCEHASH}   = "112469b9e58497a5cfa2ecb3d9eeb9d3a4151c9f";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
		
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("cabextract");
	}
}
	
	###
	### gecko
	###
	
sub install_gecko {
	${CHKPNT} = check_check_point ("gecko");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "wine_gecko-1.3-x86.msi";
		${SOURCEDIR}    = "wine_gecko-1.3-x86.msi";
		${SOURCEHASH}   = "acc6a5bc15ebb3574e00f8ef4f23912239658b41";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
		
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		system ("mkdir ${BUILDDIR}/share/wine/gecko");
		system ("cp ${BASEDIR}/source/${SOURCECODE} ${BUILDDIR}/share/wine/gecko/.");
		create_check_point ("gecko");
	}
}
	
	###
	### expat
	###
	
sub install_expat {
	${CHKPNT} = check_check_point ("expat");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "expat-2.0.1.tar.gz";
		${SOURCEDIR}    = "expat-2.0.1";
		${SOURCEHASH}   = "663548c37b996082db1f2f2c32af060d7aa15c2d";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
	
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("expat");
	}
}
	
	###
	### gperf
	###
	
sub install_gperf {
	${CHKPNT} = check_check_point ("gperf");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "gperf-3.0.4.tar.gz";
		${SOURCEDIR}    = "gperf-3.0.4";
		${SOURCEHASH}   = "e32d4aff8f0c730c9a56554377b2c6d82d0951b8";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
	
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("gperf");
	}
}
	
	###
	### ncurses
	###
	
sub install_ncurses { 
	${CHKPNT} = check_check_point ("ncurses");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "ncurses-5.9.tar.gz";
		${SOURCEDIR}    = "ncurses-5.9";
		${SOURCEHASH}   = "3e042e5f2c7223bffdaac9646a533b8c758b65b5";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${BEFORE_CONFIGURE} .= " PKG_CONFIG_LIBDIR=\"${BUILDDIR}/lib/pkgconfig\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
		${AFTER_CONFIGURE} .= " --enable-widec";
		${AFTER_CONFIGURE} .= " --enable-overwrite";
		${AFTER_CONFIGURE} .= " --with-shared";
		${AFTER_CONFIGURE} .= " --without-debug";
		${AFTER_CONFIGURE} .= " --without-ada";
		${AFTER_CONFIGURE} .= " --enable-sigwinch";
		${AFTER_CONFIGURE} .= " --enable-pc-files";
		${AFTER_CONFIGURE} .= " --enable-symlinks";
		${AFTER_CONFIGURE} .= " --disable-mixed-case";
	
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("ncurses");
	}
}
	
	
	###
	### flex
	###
	
sub install_flex { 
	${CHKPNT} = check_check_point ("flex");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "flex-2.5.35.tar.bz2";
		${SOURCEDIR}    = "flex-2.5.35";
		${SOURCEHASH}   = "c507095833aaeef2d6502e12638e54bf7ad2f24a";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
		${AFTER_CONFIGURE} .= " --infodir=${BUILDDIR}/share/info";
		${AFTER_CONFIGURE} .= " --mandir=${BUILDDIR}/share/man";
	
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("flex");
	}
}
		
	###
	### libtasn1
	###
	
sub install_libtasn1 {
	${CHKPNT} = check_check_point ("libtasn1");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "libtasn1-2.9.tar.gz";
		${SOURCEDIR}    = "libtasn1-2.9";
		${SOURCEHASH}   = "d9ca45b37c9a934672c106f9f0c3e5a6b5715be8";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
		
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("libtasn1");
	}
}
		
	###
	### gdbm
	###
	
sub install_gdbm {
	${CHKPNT} = check_check_point ("gdbm");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "gdbm-1.9.1.tar.gz";
		${SOURCEDIR}    = "gdbm-1.9.1";
		${SOURCEHASH}   = "0742a9ed8fc93fb5d5d3984d2acf99821134e2e9";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
		
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("gdbm");
	}
}
		
	###
	### readline
	###
	
sub install_readline { 
	${CHKPNT} = check_check_point ("readline");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "readline-6.2.tar.gz";
		${SOURCEDIR}    = "readline-6.2";
		${SOURCEHASH}   = "a9761cd9c3da485eb354175fcc2fe35856bc43ac";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
		
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("readline");
	}
}
		
	###
	### db
	###
	
sub install_db {
	${CHKPNT} = check_check_point ("db");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "db-4.6.21.tar.gz";
		${SOURCEDIR}    = "db-4.6.21";
		${SOURCEHASH}   = "5be3beb82e42a78ff671a3f5a4c30e5652972119";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
		${AFTER_CONFIGURE} .= " --enable-cxx";
		${AFTER_CONFIGURE} .= " --includedir=${BUILDDIR}/include/db46";
		${AFTER_CONFIGURE} .= " --program-transform-name=\"s,^db,db46,\"";
		${AFTER_CONFIGURE} .= " --enable-dump185";
		${AFTER_CONFIGURE} .= " --disable-tcl";
		
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "cd build_unix; ../dist/configure");
		build_source ("${SOURCEDIR}/build_unix", "-j 5", "db");
		install_source ("${SOURCEDIR}/build_unix", "db");
		create_check_point ("db");
	}
}
		
	###
	### sqlite
	###
	
sub install_sqlite { 
	${CHKPNT} = check_check_point ("sqlite");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "sqlite-autoconf-3070701.tar.gz";
		${SOURCEDIR}    = "sqlite-autoconf-3070701";
		${SOURCEHASH}   = "ee405037ab49f46f657a9b314e66eec6009d5fc6";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS} -DSQLITE_ENABLE_COLUMN_METADATA=1 -DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_RTREE=1 -DSQLITE_SECURE_DELETE=1 -DSQLITE_ENABLE_UNLOCK_NOTIFY=1\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
		${AFTER_CONFIGURE} .= " --enable-threadsafe";
		${AFTER_CONFIGURE} .= " --enable-dynamic-extensions";
		${AFTER_CONFIGURE} .= " --enable-readline";
		
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("sqlite");
	}
}
		
	###
	### libffi
	###
	
sub install_libffi {
	${CHKPNT} = check_check_point ("libffi");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://lion-winebuilder.googlecode.com/files";
		${SOURCECODE}   = "libffi-3.0.9.tar.gz";
		${SOURCEDIR}    = "libffi-3.0.9";
		${SOURCEHASH}   = "56e41f87780e09d06d279690e53d4ea2c371ea88";
	
		${G_CPUFLAGS} = "-g -O2 -arch i386 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "LDFLAGS=\"${G_LDFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --enable-shared=yes --enable-static=no";
		
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("libffi");
	}
}
		
	###
	### gcc
	###
	
sub install_gcc { 
	my ${CHKPNT} = check_check_point ("gcc");
	if ( ${CHKPNT} == 1 ) {
		### We just extract this for GCC, GCC will use it in its build
		${SOURCESERVER} = "ftp://gcc.gnu.org/pub/gcc/infrastructure/";
		${SOURCECODE}   = "gmp-4.3.2.tar.bz2";
		${SOURCEDIR}    = "gmp-4.3.2";
		${SOURCEHASH}   = "c011e8feaf1bb89158bd55eaabd7ef8fdd101a2c";
	
		${GMPDIR} = "gmp-4.3.2";
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		### We just extract this for GCC, GCC will use it in its build
		${SOURCESERVER} = "ftp://gcc.gnu.org/pub/gcc/infrastructure/";
		${SOURCECODE} = "mpfr-2.4.2.tar.bz2";
		${SOURCEDIR} = "mpfr-2.4.2";
		${SOURCEHASH}   = "7ca93006e38ae6e53a995af836173cf10ee7c18c";
	
		${MPFRDIR} = "mpfr-2.4.2";
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		### We just extract this for GCC, GCC will use it in its build
		${SOURCESERVER} = "ftp://gcc.gnu.org/pub/gcc/infrastructure/";
		${SOURCECODE} = "mpc-0.8.1.tar.gz";
		${SOURCEDIR} = "mpc-0.8.1";
		${SOURCEHASH}   = "5ef03ca7aee134fe7dfecb6c9d048799f0810278";
		${MPCDIR} = "mpc-0.8.1";
	
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
	
		${SOURCESERVER} = "http://mirrors-us.seosue.com/gcc/releases/gcc-4.6.1";
		${SOURCECODE}   = "gcc-4.6.1.tar.bz2";
		${SOURCEDIR}    = "gcc-4.6.1";
		${SOURCEHASH}   = "8bf66f7a71534ba564563a0ba0b2517aead8ac30";
	
		${GCCSUFFIX} = "-4.6";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --program-suffix=${GCCSUFFIX}";
		${AFTER_CONFIGURE} .= " --enable-languages=c,c++,objc,obj-c++";
	
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		### This is were we need to add links for the three previous packages
		system ( "ln -s ${BASEDIR}/build/${GMPDIR} ${BASEDIR}/build/${SOURCEDIR}/gmp" );
		system ( "ln -s ${BASEDIR}/build/${MPFRDIR} ${BASEDIR}/build/${SOURCEDIR}/mpfr" );
		system ( "ln -s ${BASEDIR}/build/${MPCDIR} ${BASEDIR}/build/${SOURCEDIR}/mpc" );
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("gcc");
	}
}
		
	###
	### wine
	###
	
sub install_wine {
	${CHKPNT} = check_check_point ("wine");
	if ( ${CHKPNT} == 1 ) {
		${SOURCESERVER} = "http://softlayer.dl.sourceforge.net/project/wine/Source";
		${SOURCECODE}   = "wine-1.4-rc3.tar.bz2";
		${SOURCEDIR}    = "wine-1.4-rc3";
		${SOURCEHASH}   = "1cce9110f23d5893dc4c12a3a116964e336e75c0";
	
		${G_CPUFLAGS} = "-g -O2 -m32 -mmmx -msse -msse2 -msse3 -mfpmath=sse";
		${G_LDFLAGS}  = "-L/usr/lib -L${BUILDDIR}/lib -L${X11DIR}/lib -framework CoreServices -lz -lGL -lGLU ${G_CPUFLAGS}";
		${G_CPPFLAGS} = "-I/usr/include -I${BUILDDIR}/include -I${X11DIR}/include";
		${G_CFLAGS}   = "-L/usr/lib -L${BUILDDIR}/lib ${G_CPUFLAGS}";
		${G_CXXFLAGS} = "${G_CFLAGS}";
	
		${BEFORE_CONFIGURE} = "CC=\"gcc-4.6\"";
		${BEFORE_CONFIGURE} .= " LDFLAGS=\"${G_LDFLAGS} -framework CoreServices -lz -Wl,-no_pie\"";
		${BEFORE_CONFIGURE} .= " CPPFLAGS=\"${G_CPPFLAGS} -D_DARWIN_NO_64_BIT_INODE\"";
		${BEFORE_CONFIGURE} .= " CFLAGS=\"${G_CFLAGS}\"";
		${BEFORE_CONFIGURE} .= " CXXFLAGS=\"${G_CXXFLAGS}\"";
		${AFTER_CONFIGURE} = "--prefix=${BUILDDIR}";
		${AFTER_CONFIGURE} .= " --disable-win16";
		${AFTER_CONFIGURE} .= " --disable-win64";
		${AFTER_CONFIGURE} .= " --without-alsa";
		${AFTER_CONFIGURE} .= " --without-capi";
		${AFTER_CONFIGURE} .= " --with-cms";
		${AFTER_CONFIGURE} .= " --with-coreaudio";
		${AFTER_CONFIGURE} .= " --with-cups";
		${AFTER_CONFIGURE} .= " --with-curses";
		${AFTER_CONFIGURE} .= " --without-esd";
		${AFTER_CONFIGURE} .= " --with-fontconfig";
		${AFTER_CONFIGURE} .= " --with-freetype";
		${AFTER_CONFIGURE} .= " --without-gphoto";
		${AFTER_CONFIGURE} .= " --with-glu";
		${AFTER_CONFIGURE} .= " --with-gnutls";
		${AFTER_CONFIGURE} .= " --without-gsm";
		${AFTER_CONFIGURE} .= " --without-hal";
		${AFTER_CONFIGURE} .= " --without-jack";
		${AFTER_CONFIGURE} .= " --with-jpeg";
		${AFTER_CONFIGURE} .= " --without-ldap";
		${AFTER_CONFIGURE} .= " --with-mpg123";
		${AFTER_CONFIGURE} .= " --without-nas";
		${AFTER_CONFIGURE} .= " --without-openal";
		${AFTER_CONFIGURE} .= " --with-opengl";
		${AFTER_CONFIGURE} .= " --with-openssl";
		${AFTER_CONFIGURE} .= " --without-oss";
		${AFTER_CONFIGURE} .= " --with-png";
		${AFTER_CONFIGURE} .= " --with-pthread";
		${AFTER_CONFIGURE} .= " --without-sane";
		${AFTER_CONFIGURE} .= " --with-tiff";
		${AFTER_CONFIGURE} .= " --without-v4l";
		${AFTER_CONFIGURE} .= " --with-xcomposite";
		${AFTER_CONFIGURE} .= " --with-xcursor";
		${AFTER_CONFIGURE} .= " --with-xinerama";
		${AFTER_CONFIGURE} .= " --with-xinput";
		${AFTER_CONFIGURE} .= " --with-xml";
		${AFTER_CONFIGURE} .= " --with-xrandr";
		${AFTER_CONFIGURE} .= " --with-xrender";
		${AFTER_CONFIGURE} .= " --with-xshape";
		${AFTER_CONFIGURE} .= " --with-xshm";
		${AFTER_CONFIGURE} .= " --with-xslt";
		${AFTER_CONFIGURE} .= " --with-xxf86vm";
		${AFTER_CONFIGURE} .= " --with-x";
		${AFTER_CONFIGURE} .= " --x-include=${X11DIR}/include";
		${AFTER_CONFIGURE} .= " --x-lib=${X11DIR}/lib";
		
		get_source ("${SOURCESERVER}", "${SOURCECODE}", "${BASEDIR}/source/${SOURCECODE}");
		check_sha ("${BASEDIR}/source/${SOURCECODE}", "${SOURCEHASH}");
		extract_source ("${BASEDIR}/source/${SOURCECODE}", "${BASEDIR}/build");
		configure_source ("${SOURCEDIR}", "${BEFORE_CONFIGURE}", "${AFTER_CONFIGURE}", "");
		build_source ("${SOURCEDIR}", "-j 5");
		install_source ("${SOURCEDIR}");
		create_check_point ("wine");
	}
}

sub run_main {
	install_pkg_config;
	install_libiconv;
	install_gettext;
	install_jpeg;
	install_tiff;
	install_libpng;
	install_glib;
	install_libxml2;
	install_libxslt;
	install_mpg123;
	install_gsm;
	install_freetype;
	install_fontconfig;
	install_lcms;
	install_lzo2;
	install_libgpgerror;
	install_libgcrypt;
	install_gnutils;
	install_unixodbc;
	install_libexif	;
	install_libusb;
	install_libusbcompat;
	install_gd;
	install_libgphoto2;
	install_jasper;
	install_libicns;
	install_sdl;
	install_sdlnet;
	install_sdlsound;
	install_dosbox;
	install_orc ;
	install_libogg ;
	install_libvorbis;
	install_libtheora;
	install_gstreamer;
	install_gstpluginsbase;
	install_cabextract ;
	install_gecko;
	install_expat;
	install_gperf;
	install_ncurses ;
	install_flex ;
	install_libtasn1;
	install_gdbm;
	install_readline ;
	install_db;
	install_sqlite ;
	install_libffi;
	install_gcc ;
	install_wine;
}
	
run_main;
print "Getting the latest \"winetricks\".\n";
system ("cd ${TMPDIR};svn checkout http://winetricks.googlecode.com/svn/trunk/ winetricks-read-only");
system ("cp ${TMPDIR}/winetricks-read-only/src/winetricks ${BUILDDIR}/bin");
	
print "Build Complete!\n";
print "You'll need to set the following environment variables:\n";
print "  export DYLD_FALLBACK_LIBRARY_PATH=\"${BUILDDIR}/lib:${X11DIR}/lib:/usr/lib\"\n";
print "  export PATH=\"${BUILDDIR}/bin:\${PATH}\"\n";
